#ifndef CEVENT_H_
#define CEVENT_H_

#include <stddef.h>
#include "EventDefinitions.h"

class CEvent
{

private:
	EVENT_TYPE			m_nEventID;	
	TBaseEventData*		m_pData;
	bool				m_bHandle;
	unsigned int		m_unRefs;

public:
	
	//Constructor
	CEvent(EVENT_TYPE eventID, TBaseEventData* pData = NULL)
	{
		m_nEventID = eventID;
		m_pData = pData;
		m_bHandle = false;
		m_unRefs = 0;
	}

	//Destructor
	~CEvent() 
	{ 
		if(m_pData)
		{
			m_pData->~TBaseEventData();
			delete m_pData;
		}
		m_pData = NULL; 
	}

	//	ACCESSORS
	const EVENT_TYPE GetEventID()	{return m_nEventID;}
	TBaseEventData*	GetData()		{return m_pData;}
	const bool GetWasHandle() {return m_bHandle;}
	const unsigned int GetReferences() { return m_unRefs;}
	
	//Mutators
	void SetData(TBaseEventData* pData)
	{ 
		if(pData)
		{
			delete m_pData;
			m_pData = pData;
		}
		else
			m_pData = NULL;
	}

	void SetWasHandle(bool bWasHandle){m_bHandle = bWasHandle;}
	void AddRef(){ ++m_unRefs;}
	void SubtractRef()
	{ 
		--m_unRefs;
		if(m_unRefs < 0)
			m_unRefs = 0;
	}


};

#endif